# coding: utf-8

from leancloud import Object
from leancloud import Query
from leancloud import LeanCloudError
from flask import Blueprint
from flask import request
from flask import redirect
from flask import url_for
from flask import render_template
import sys
sys.path.append('./cloud')
import games

mini_view = Blueprint('mini', __name__)

@mini_view.route('/getGamesList', methods=['GET'])
def getGamesList():
    """
    获取游戏列表
    """
    userID = request.args.get("userID")
    return games.getList(userID)

@mini_view.route('/addFavorite', methods=['GET'])
def addFavorite():
    """
    收藏游戏
    """
    userID = request.args.get("userID")
    gameID = request.args.get("gameID")
    return games.addFavorite(gameID, userID)

@mini_view.route('/rmFavorite', methods=['GET'])
def rmFavorite():
    """
    取消收藏
    """
    userID = request.args.get("userID")
    gameID = request.args.get("gameID")
    return games.rmFavorite(gameID, userID)

@mini_view.route('/clickGame', methods=['GET'])
def clickGame():
    gameID = request.args.get("gameID")
    return games.click(gameID)
